package com.unit.util;

public class EnumUtils {
    
    public static Enum getEnumByRefection(Class type, int index) throws Throwable{
    	Object[] types = type.getEnumConstants();
        for (Object t : types) {
            if ((Integer)(t.getClass().getMethod("getIndex").invoke(t)) == index) {
                return (Enum)t;
            }
        }
        throw new AssertionError("不能够映射:" + index + "到枚举" + type.getSimpleName());
    }
}
